<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>设置新密码</title>
    <link rel="stylesheet" href="__MEMBER__/css/base.css" type="text/css">
    <link rel="stylesheet" href="__MEMBER__/css/global.css" type="text/css">
    <link rel="stylesheet" href="__MEMBER__/css/register.css" type="text/css">
    <link rel="stylesheet" href="__MEMBER__/css/footer.css" type="text/css">
    <!--[if lt IE 9]-->
    <script type="text/javascript" src="__PUBLIC__/jquery-1.10.2.min.js"></script>
    <!--[endif]-->
    <script type="text/javascript" src="__PUBLIC__/jquery-2.0.3.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/assets/plugins/layer-v2.0/layer/layer.js"></script>
  </head>
<body>
<div class="top_wrapper pt20"  style="background: url(/Public/assets/img/header_bg.png) repeat-x;width: 100%;height: 160px;color: #fff;">
	<div class="w990 bc header">
        <div id="logo"><h1 class="fl"><a href="/"><img width="180" height="50" alt="CHP" src="__PUBLIC__/logo.png"></a></h1><span class="fl">重置密码</span></div>
	</div>

</div>

<div class="center_wrapper pb100">
	<div class="w990 bc">
		<div class="reg-form mt10">
		   <form name="rest_form" method="post" action=""> 
		        <div class="input-tip"></div> 
		    	<div id="form-item-account" class="form-item form-item-account">
		            <label>设 置 密 码</label>
					<input id="password" type="password" placeholder="请设置密码" maxlength="20" autocomplete="off" class="field" name="password">
		        </div>
		        <div class="input-tip"></div> 
		    	<div id="form-item-account" class="form-item form-item-account">
		            <label>确 认 密 码</label>
					<input type="password" placeholder="请输入确认密码" maxlength="20" autocomplete="off" class="field" name="cpassword">
		        </div>
		        <div class="input-tip"></div> 

				<!-- <div class="form-item form-item-authcode">
		            <label>验&#12288;证&#12288;码</label>
		            <input type="text" placeholder=" " class="field form-authcode" maxlength="4"  name="chkcode">
		            <img title="看不清,换一换" class="img-code" src="<{:U('Users/chkcode')}>">
		        </div> -->
				<div class="input-tip"></div>
				<div>
				<input class="btn-register"  value="确认找回" type="submit"> 
				</div>
		    </form>
	    </div>
	</div>
</div>	
    <!-- 底部版权 end -->
	<script type="text/javascript" src="__PUBLIC__/jquery.validate.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/assets/js/hex_sha1.js"></script>
	<script type="text/javascript">
		$(function(){
			$("form[name=rest_form]").validate({
				submitHandler: function(form) { 
				var password = $('input[name="password"]');
        		var re_password = $('input[name="cpassword"]');
				if ($.trim(password.val()) != '' || $.trim(re_password.val()) != '') {
		            // 对发送出去的代码进行加密,  如果超过40位, 当做已经加密过, 不再加密
		            if (password.val().length < 40 ) {
		                password.val( $.trim( hex_sha1( password.val() ) ) );
		                re_password.val( $.trim( hex_sha1( re_password.val() ) ) );
		            }
	        	}
	        	var data = $("form[name=rest_form]").serialize();
		        $.ajax({
			   	    url : "{:U('Public/modifyPassword','','')}",
					data:data,
			 		type : "post",
			 		dataType : "json",
			 		success : function(data){
			  			if(!data.status){
			  				layer.msg('找回密码失败！', {
												  icon: 2,
												  time: 2000 //2秒关闭（如果不配置，默认是3秒）
												});
			  				password.val("");
		                	re_password.val("");
			  			}else{
			  				layer.msg(data.info, {
												  icon: 1,
												  time: 2000
												},function(){
													window.location.href = data.url;
												});   

			  			}
			 		}
		     	})
				},
				errorElement : "span",
				errorPlacement: function(error, element) {
				    error.appendTo( element.parent().next());
				},
				rules: {
					password : {
						required : true,
						rangelength:[4,20]
					},
					cpassword : {
						required : true,
						equalTo : '#password'
					}
				},
				messages : {
					password : {
						required : '*请输入密码',
						rangelength : '*请输入4至20位密码'
					},
					cpassword : {
						required : '*请输入确认密码',
						equalTo : '两次密码输入不一致'
					}
				}
           



			

 
	
		})


		  

			})
	
	/*//提交要修改的密码
			function setPassword(){
				var mobile=$('#mobile').val();
				var password=$('#password').val();
				$.ajax({
				url : "<{:U('Users/modifyPassword','','')}>",
				data:{mobile:mobile,password:password},
		 		type : "post",
		 		dataType : "json",
		 		success : function(data){
		  			if(!data.status){
		  				layer.msg('找回密码失败！', {
											  icon: 2,
											  time: 2000 //2秒关闭（如果不配置，默认是3秒）
											});
		  			}else{
		  				layer.msg('找回密码成功！', {
											  icon: 1,
											  time: 2000 //2秒关闭（如果不配置，默认是3秒）

											});   

		  			}
		 		}
			 })
			}*/
	</script> 
    </body>
</html>